package org.musicPlayerServer.server;

import org.apache.log4j.PropertyConfigurator;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.musicPlayerServer.business.Controller;
import org.musicPlayerServer.gui.GuiManager;

public class MusicServer {


    public MusicServer() throws Exception{
	PropertyConfigurator.configure("log4j.properties");
	Server server = new Server(8080);
	GuiManager.getInstance().init();
	Controller.getInstance().init("/home/flo/Musique");
	server.setHandler(new MainHandler());




	/*
	ServletHolder jspSH = new ServletHolder(org.apache.jasper.servlet.JspServlet.class); jspSH.setInitParameter("trimSpaces" , "true");
	jspSH.setInitParameter("mappedFile" , "true");
	jspSH.setInitParameter("classdebuginfo", "true");
	jspSH.setInitParameter("keepGenerated" , "true");
	jspSH.setInitParameter("development" , "true");
	jspSH.setInitParameter("scratchDir" , "./target/scratch");
	//ctx.addServlet(jspSH, "*.jsp");
	 */




/*
	ResourceHandler resource_handler = new ResourceHandler();
	resource_handler.setDirectoriesListed(true);
	resource_handler.setWelcomeFiles(new String[]{ "index.html" });

	resource_handler.setResourceBase(".");

	HandlerList handlers = new HandlerList();
	handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
	server.setHandler(handlers);
*/




	server.start();
	server.join();
    }

    public static void main(String[] args) throws Exception    {
	MusicServer ms = new MusicServer();
	ms.setSharedRootFolder("/home/flo/Musique");
    }

    public void setSharedRootFolder(String string) {
	
	
    }

}
